package edu.hainnu.niit.controller;

import edu.hainnu.niit.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * TODO
 *
 * @package_name edu.hainnu.niit.controller
 * @auther GGB
 * @date 2021/12/11
 * @time 17:20
 */
@Controller

public class JumpController {
    @Resource
    INoticeService iNoticeService;
    @Resource
    ICarouselService iCarouselService;
    @Resource
    IProductService iProductService;
    @Resource
    INewsService iNewsService;
    @Resource
    IClassificationService iClassificationService;
    @Resource
    IAuctionHomeService iAuctionHomeService;
    @Resource
    IAuctionService iAuctionService;
    @GetMapping("/")
    public String index(HttpSession session){
        //存放最新通知
        session.setAttribute("notice",iNoticeService.queryNoticeService());
        //存放轮播图
        session.setAttribute("carouse",iCarouselService.carouselService(3));
        //存放最新5个产品信息
        session.setAttribute("productList",iProductService.productService(5));
        //存放8个最新精品产品信息
        session.setAttribute("productList1",iProductService.Is_goodService(8));
        //存放4个精品产品信息
        session.setAttribute("productList2",iProductService.Is_goodService2(4));
        //最新咨询
        session.setAttribute("LatestConsultation",iNewsService.LatestConsultation(5));
        //行业动态
        session.setAttribute("IndustryDynamics",iNewsService.IndustryDynamics(5));
        //热门咨询
        session.setAttribute("PopularConsultation",iNewsService.PopularConsultation(5));
        //分类查询
        session.setAttribute("Classification",iClassificationService.queryService());
        return "index";
    }
    @GetMapping("jump/about")
    public String about(){

    return"about";
    }

    @GetMapping("jump/auction")
    public String auction(HttpSession session){
        session.setAttribute("auctionMaxClickNumByTwo",iAuctionHomeService.auctionMaxClickNumByTwo());
        //拍卖展示
        session.setAttribute("auctionMaxPriceByEight",iAuctionHomeService.auctionMaxPriceByEight());
        //拍卖新闻
        session.setAttribute("PNewsMaxClickNumByThree",iAuctionHomeService.PNewsMaxClickNumByThree());
        return"auction";
    }

    @GetMapping("jump/book")
    public String book(){

        return"book";
    }

    @GetMapping("jump/contact")
    public String contact(){

        return"contact";
    }

    @GetMapping("jump/detail")
    public String detail(Model model,Integer id){
        model.addAttribute("newsById",iNewsService.queryNewsByIDService(id));

        return"detail";
    }

    @GetMapping("jump/lot")
    public String lot(Integer type){

        return"lot";
    }

    @GetMapping("jump/news")
    public String news(){

        return"news";
    }

    @GetMapping("jump/product")
    public String product(){

        return"product";
    }

    @GetMapping("jump/product_xq")
    public String product_xq(Model model,Integer id){
        model.addAttribute("ProductByID",iProductService.queryProductByIDService(id));
        return"product_xq";
    }

    @GetMapping("jump/lot_xq")
    public String aution_xq(Model model,Integer id){
        model.addAttribute("lotByID",iAuctionService.queryAuctionByIDService(id));
        return"lot_xq";
    }
}
